package cn.itsource.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 用来装在异步请求的aajax数据
 *
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AjaxResult {


    private String   success =Constant.RETURN_SUCCESS;

    private Boolean  result = true;

    private String   message = "成功";

    private Object data;

    //返回成功,不带数据
    public static AjaxResult success(){
        return new AjaxResult();
    }
    //返回成功,携带数据
    public static AjaxResult success(Object date){
        return new AjaxResult(Constant.RETURN_SUCCESS,true,"成功",date);
    }
    //返回失败,
    public static AjaxResult returnFailure(String message){
        return new AjaxResult(Constant.RETURN_SUCCESS,false,message,null) ;
    }
    //返回失败,自定义异常
    public static AjaxResult returnFailure(String success,String message){
        return new AjaxResult(success,false,message,null);
    }



}
